# -*- coding: ytf-8 -*-
# 外网工具
import re
import requests


def get_public_ip():
    """
    获取外网ip地址
    """
    url = 'https://api.ipify.org'
    try:
        response = requests.get(url, timeout=60)
    except Exception as e:
        print('获取外网ip超时')
        return None
    public_ip = re.findall(r'\d+\.\d+\.\d+\.\d+', response.text)[0]
    return public_ip
